package effectlistener;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowListener;
class MyFrame extends Frame{
	TextField t1;
	Button b1;
	int flag=0;
	MyFrame()
	{
		setLayout(new FlowLayout());
		t1=new TextField(12);
		b1=new Button("HIDE/SHOW");
		b1.setActionCommand("b1");
		b1.addActionListener((ActionListener) new action1());
		add(t1);
		add(b1);
		setBounds(100, 100, 200, 200);
		setVisible(true);
	}
	class action1 implements ActionListener
	{
		public void actionPerformed(ActionEvent e)
		{
			if(e.getActionCommand().equals("b1")&&flag==0)
			{
				t1.setVisible(false);
				flag=1;
			}
			else if(e.getActionCommand().equals("b1")&&flag==1)
			{
				t1.setVisible(true);
				flag=0;
			}
			
		}
	}
    
}


public class TestButton {

	public static void main(String[] args) {
	   MyFrame myframe=new MyFrame();
	}

}
